package com.info.zhiduoduo.pay.sdk.zhaoshangbank.model.common;

import com.alibaba.fastjson.JSONObject;

import lombok.Data;

@Data
public class RequestDTO<T> {

	private HeadReqDTO head;

	private T body;

	public static RequestDTO<?> of(HeadReqDTO reqDTO, Object body) {
		RequestDTO<Object> dto = new RequestDTO<>();
		dto.head = reqDTO;
		dto.body = body;
		return dto;
	}

	public static JSONObject toJson(HeadReqDTO head, Object body) {
		RequestDTO<Object> dto = new RequestDTO<>();
		dto.head = head;
		dto.body = body;
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("request", dto);
		return jsonObject;
	}

	public JSONObject toJson() {
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("request", this);
		return jsonObject;
	}

}
